<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
	$(document).ready(function(){
		/*var latlng = new google.maps.LatLng(<?php echo $duan['Duan']['lat'];?>, <?php echo $duan['Duan']['lon']?>);
		var myOptions = {
		  zoom: 13,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map"),myOptions);
		var marker = new google.maps.Marker({
			position: latlng, 
			map: map, 
			title:"<?php echo $duan['Duan']['tieude'];?>"
		});
		map.setCenter(latlng);
		*/
		$("#PostFormClassified").validate({ 
	        rules: { 
              "tieude":"required",
              "noidung":"required",
			  "tenlienhe":"required",
			  "sdtlienhe":{
					required: true,
					numberic: true
				},
			  "email":{
                required:true,
                email:true
              },
			  "answercapcha":{
				required:true,
			  }
	        }, 
	        messages: { 
              "tieude": "Nhập tiêu đề bài viết",
              "noidung": "Nhập nội dung bài viết",
			  "tenlienhe": "Nhập tên liên hệ",
			  "sdtlienhe": {
					required: "Nhập số điện thoại",
					numberic: "Phải là số"
				},
			  "email": {
						required: "Nhập email",
						email : "Nhập đúng định dạng email"
				},
				"answercapcha": {
					required: "Chưa trả lời câu hỏi bảo mật",
				}
	        } 
	    }); 
	});
</script>
<script type="text/javascript">
	var RecaptchaOptions = {
	   theme : 'clean',
	   tabindex : 2
	};
</script>
<div class="title">
	<?php echo $duan['Duan']['tieude']; ?><div style="font-size:11px;color:#0b4b5e;padding:5px 0px 0px 0px"><?php echo $duan['Duan']['diachi']; ?></div>
</div>
<div class="intro_content">
	<div class="clearfix">
		<div class="intro_left">
			
			<div class="clearfix">
				<!--<div id="map" style="float: right; width: 400px;height: 300px">a</div>-->
				<?php echo $duan['Duan']['noidung']; ?>				
			</div>
			
			
			<div class="post-rao">			
				<form action="<?php echo $this->webroot;?>tinraos/add" method="post" class="edit-form" id="PostFormClassified">
					<table class="contact-table">				
						<tr>
							<td>Tiêu đề:</td>
							<td>
								<input type="hidden" name="idduan" value="<?php echo $duan['Duan']['id']; ?>" />
								<input type="hidden" name="addfrduan" value="1" />
								<input type="text" name="tieude" />
							</td>
						</tr>
						<tr>
							<td>Nội dung:</td>
							<td><textarea class="autogrow" name="noidung" cols="5" rows="10"></textarea></td>
						</tr>
						
						<tr>
							<td>Tên liên hệ:</td>
							<td><input type="text" name="tenlienhe" /></td>
						</tr>
						<tr>
							<td>Số điện thoại liên hệ:</td>
							<td><input type="text" name="sdtlienhe" /></td>
						</tr>
						<tr>
							<td>Email liên hệ:</td>
							<td><input type="text" name="email" /></td>
						</tr>
						<tr>
							<td>Câu hỏi xác nhận:</td>
							<td>
								<?php
									//$publickey = "6LcMKMkSAAAAAMPaRiwoALz6kJypcz1072dgGXf5"; // you got this from the signup page
									//echo recaptcha_get_html($publickey);
									echo 'Kết quả của phép tính '.$mathCaptcha.'';
									
								?>
							</td>
						</tr>
						<tr>
							<td>Trả lời (trả lời bằng số):</td>
							<td><input type="text" name="answercapcha" /></td>
						</tr>
						<tr>
							<td></td>
							<td><?php echo $this->Session->flash();?></td>
						</tr>
						<tr>
							<td></td><td style="float: right"><input type="submit" value="Đăng tin rao" /></td>
						</tr>
					</table>
					
				</form>
			</div>
		</div><!--End left-->
		<div class="intro_right">                   
			<div class="box_right">
				<div class="box_right_top"></div>
				<div class="box_right_center">
					<div class="box_right_title" style="font-weight:bold;color:#0b4b5e">CÁC DỰ ÁN KHÁC</div>
					<div class="box_right_content">
						<ul>
							<?php foreach($otherduans as $oduan):?>
							<li><a href="<?php echo $this->webroot;?>project-<?php echo $oduan['Duan']['id'];?>/<?php echo preg_replace('/\s+/', '-', $changetv->changetvkd($oduan['Duan']['tieude']))?>.html"><?php echo $oduan['Duan']['tieude'];?></a></li>
							<?php endforeach;?>
						</ul>
					</div>                      
				</div>
				<div class="box_right_bottom"></div>
			</div>
			<div class="box_right">
				<div class="box_right_top"></div>
				<div class="box_right_center">
					<div class="box_right_title" style="font-weight:bold;color:#0b4b5e">CÁC TIN RAO</div>
					<div class="box_right_content">
						<?php foreach($tinraos as $tinrao): ?>
							<div class="box_project box_rao">                                    
								<span class="title"> <a href="<?php echo $this->webroot;?>classified-ads-<?php echo $tinrao["Tinrao"]["id"];?>/<?php echo preg_replace('/\s+/', '-', $changetv->changetvkd($tinrao["Tinrao"]["tieude"]));?>.html" title="<?php echo $tinrao["Tinrao"]["tieude"];?>"><?php echo $this->Text->truncate($tinrao["Tinrao"]["tieude"], 30, array('ending'=>'...','exact' => false))?></a></span>
								<div class="content">
									<span class="label">Ngày đăng:</span><span class="date-post"><?php echo date('d-m-Y', strtotime($tinrao["Tinrao"]["ngaydang"]));?></span>
									<div class="ndtinrao">
										<?php //echo $tinrao["Tinrao"]["noidung"];?>
										<?php echo $this->Text->truncate($tinrao["Tinrao"]["noidung"], 200, array('ending'=>'...','exact' => false)); ?>
									</div>
								</div>
							</div>
						<?php endforeach; ?>                           
					</div>
					<div class="paging">
						<div class="paging">
							<?php if($this->Paginator->hasPrev()) {
									echo $this->Paginator->prev('<< ' . __('trước', true), array('class'=>'PrevPg'), null, array('class'=>'disabled PrevPg'));
									echo ' |' ;
								}
							?>
							<?php echo $this->Paginator->numbers();?>
							<?php if($this->Paginator->hasNext()) {
								echo '| ';
								echo $this->Paginator->next(__('sau', true) . ' >>', array('class' => 'NextPg'), null, array('class' => 'disabled NextPg'));					
							}
							?>
						</div>
					</div>
				</div>
				<div class="box_right_bottom"></div>
			</div>		
		</div><!--End right-->
	</div>
</div>